package com.yufei.entity.query;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.yufei.pfw.service.PfwService;
import com.yufei.utils.SpringUtils;

public abstract class AbstractQuery<Q extends BaseQueryInfo,T> {
	private static Log mLog = LogFactory
			.getLog(AbstractQuery.class);
	protected PfwService  pfwService=(PfwService) SpringUtils.getBeanFromBeanContainer(PfwService.class);
	private List<T> searchResult= null;
    /**
     * @return
     */
    private boolean checkValidQueryInfo(){
    	boolean isValid=true;
    	if(queryInfo==null){
    		mLog.info("queryInfo不能为空!");
    		isValid=false;
    	}
    	return isValid;
    }
	public AbstractQuery(Q queryInfo) {
		super();
		this.queryInfo = queryInfo;

		if(!checkValidQueryInfo()){
			throw new IllegalArgumentException();
		}
		
	}

	protected Q queryInfo=null;
	
	
	public abstract void  query();
	
	
	
	
	
    public int getCurrentPage(){
    	return queryInfo.getCpn();
    }
   
    public int getPageSize(){
    	return queryInfo.getCount();
    }
 
	public List<T> getSearchResult() {
		return searchResult;
	}

	public void setSearchResult(List<T> searchResult) {
		this.searchResult = searchResult;
	}

	public Q getQueryInfo() {
		return queryInfo;
	}

	public void setQueryInfo(Q queryInfo) {
		this.queryInfo = queryInfo;
	}
     
}
